var t = getApp();

Page({
    data: {
        debtId: "",
        listData: [],
        keyWord: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "会员管理"
        }), t.debtId && (this.data.debtId = t.debtId), this.setData({
            plugin_setting: wx.getStorageSync("yz_basic_info").plugin_setting.debt_shop || {}
        });
    },
    onReady: function() {},
    init: function() {
        this.setData({
            listData: [],
            isLoadMore: !0,
            page: 1,
            total_page: 0
        });
    },
    blackTap: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    tapWkd: function() {
        this.init(), this.getData(), console.log(this.data.keyWord);
    },
    onShow: function() {
        this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.debt-shop.frontend.owner.vipList");
        t._getNetWork({
            url: e,
            data: {
                debtor_id: this.data.debtId,
                member_kwd: this.data.keyWord
            },
            success: function(t) {
                var e = t.data;
                1 == e.result && (console.log(e), a.data.isLoadMore = !0, a.data.total_page = e.data.last_page, 
                a.data.total_page || (a.data.total_page = 0), a.setData({
                    listData: e.data.data,
                    owner_common_credit: e.data.owner_common_credit
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    addToVip: function(t) {
        var a;
        t.currentTarget.dataset.key ? a = "/packageF/debt/vipAddindex/vipAddindex?vid=" + t.currentTarget.dataset.item.has_one_vip_member.uid + "&coupon=true&debtId=" + this.data.debtId + "&credit=" + this.data.owner_common_credit + "&cvid=" + t.currentTarget.dataset.item.id : a = "/packageF/debt/vipAddindex/vipAddindex?debtId=" + this.data.debtId + "&credit=" + this.data.owner_common_credit;
        wx.navigateTo({
            url: a
        });
    },
    getMoreData: function() {
        var a = this, e = "";
        this.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        e = t.getNetAddresss("plugin.debt-shop.frontend.owner.vipList"), t._postNetWork({
            url: e,
            data: {
                page: this.data.page,
                debtor_id: this.data.debtId,
                member_kwd: this.data.keyWord
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.data.isLoadMore = !0, a.setData({
                    listData: a.data.listData.concat(e.data.data)
                })) : (a.data.page = a.data.page - 1, a.isLoadMore = !1, wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    }
});